<?php
namespace Common\Taglib;

class tag
{
    public function run($attr)
    {
		$startrow  = intval($attr['startrow']);
        $sort = $attr['sort'] ? trim($attr['sort']) : 'hot';
        if ($sort == 'hot') {
            $order = 'sort DESC, count_question DESC';
        }
        if ($sort == 'new') {
            $order = 'addtime DESC';
        }
        $cat = intval($attr['cid']);
        $field = trim($attr['field']);
        $num = empty($attr['num']) ? 15 : intval($attr['num']);
        $page = intval($attr['page']);
        if (!empty($cat)) {
            $map['cat'] = $cat;
        }
        $map['audit'] = 1;
        $result = D('Tag')->get_list($map, $page, $order, $num,false,$startrow);
	
        return $result;
    }
}